﻿@inject IFlowService fService
@{
    var lstAll = fService.GetAll();
    ViewData["Title"] = "流程实例 管理";

}
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-lg-12">
            <div class="ibox float-e-margins">
                <div class="ibox-content text-center p-md ibox-content-search">
                    <form class="form-horizontal" datatable="tableGrid">
                        <div class="form-group col-md-4">
                            <label for="keyWord" class="col-md-3 control-label text-right">流程</label>
                            <div class="col-md-9">
                                <select class="select2" name="FlowId" id="FlowId">
                                    <option value="">请选择</option>
                                    @{
                                        if (lstAll != null && lstAll.Count > 0)
                                        {
                                            foreach (var item in lstAll)
                                            {
                                                <option value="@item.FlowId">@item.FlowName</option>
                                            }
                                        }
                                    }
                                </select>
                            </div>
                        </div>
                        <div class="form-group col-md-4">
                        <label for="keyWord" class="col-md-3 control-label text-right">流程状态</label>
                        <div class="col-md-9">
                            <select class="select2" name="ProcessStatus" id="ProcessStatus">
                                <option value="">请选择</option>
                                @{
                                    var enmuLst = ConvertHelper.ToEnumList(typeof(InsStateEnum), false);
                                    foreach (var item in enmuLst)
                                    {
                                        <option value="@item.Key">@item.Value</option>
                                    }
                                }
                            </select>
                        </div>
                </div>
                <div class="form-group col-md-4">
                    <label for="keyWord" class="col-md-3 control-label text-right">关键字</label>
                    <div class="col-md-9">
                        <input id="keyWord" name="keyWord" class="form-control" placeholder="关键字" />
                    </div>
                </div>

                <div class="col-md-12">

                    <a class="btn  btn-danger  pull-right btn-rounded btn-outline btn-delete"><i class="fa fa-trash"></i>删  除</a>
                    <label class="pull-right">   </label>
                    <a class="btn  btn-primary pull-right btn-rounded btn-outline" asp-action="Edit"><i class="fa fa-plus"></i>新  增</a>
                    <label class="pull-right">   </label>
                    <a class="btn btn-primary pull-right btn-rounded btn-search"><i class="fa fa-search"></i>搜  索</a>
                </div>
                </form>
            </div>
            </div>
        </div>
    </div>
    <div class="row">
        <div class="col-lg-12">
            <div class="ibox float-e-margins">
                <div class="ibox-content text-center p-md">
                    <div class="table-responsive">
                        <table class="table table-striped table-bordered table-hover dataTables" id="tableGrid">
                            <thead>
                                <tr>
                                    <td>
                                        <div class="i-checks">
                                            <label> <input type="checkbox" class="thead checkall" title="全选" /></label>
                                        </div>
                                    </td>
                                    <td> 实例id</td>
                                    <td> 标题</td>
                                    <td> 启动时间</td>
                                    <td> 结束时间</td>
                                    <td> 状态</td>
                                    <td> 最后修改时间</td>
                                    <td>操作</td>
                                </tr>

                            </thead>

                            <tfoot>

                                <tr>
                                    <td>
                                        <div class="i-checks">
                                            <label> <input type="checkbox" class="tfoot checkall" title="全选" /></label>
                                        </div>
                                    </td>
                                    <td> 实例id</td>
                                    <td> 标题</td>
                                    <td> 启动时间</td>
                                    <td> 结束时间</td>
                                    <td> 状态</td>
                                    <td> 最后修改时间</td>
                                    <td>操作</td>
                                </tr>
                            </tfoot>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
@section scripts{
    <script type="text/javascript">

        $(document).ready(function () {
            $(".form-horizontal").CustomForm({
                isValidate: false,
                isTable: false,
                Init: true,
            });
    var table = $(".dataTables").CustomForm({
    isValidate: false,
    isTable: true,
    "order": [[1, "desc"]], //默认排序
    deleteUrl:"@Url.Action("Delete")",
    ajaxUrl: "@Url.Action("ForGrid")",
    "columns": [
    CONSTANT.DATA_TABLES.COLUMN.CHECKBOX("ProcessId")
     , {

         "name": "ProcessId",
         "data": "ProcessId",
         "title": " 实例Id",
         "sDefaultContent": "",
         "type": 'string',
         "format": '',
         "bSortable": true

     }

                        ,{

                        "name": "Title",
                        "data":"Title",
                        "title": " 标题",
                        "sDefaultContent": "",
                        "type": 'string',
                        "format":'',
                        "bSortable":true

                    }
                     , {

                         "name": "OwnerUserId",
                         "data": "OwnerUserId",
                         "title": " 所有者",
                         "sDefaultContent": "",
                         "type": 'string',
                         "format": '',
                         "bSortable": true

                     }
                        ,{

                            "name": "StartDate",
                        "data": "StartDate",
                        "title": " 开始时间",
                        "sDefaultContent": "",
                        "type": 'string',
                        "format":'',
                        "bSortable":true
                         , render: function (data, type, row) {
                             return row.StartDate;
                         }
                        }
                    , {
                        "name": "EndDate",
                        "data": "EndDate",
                        "title": " 结束时间",
                        "sDefaultContent": "",
                        "type": 'int',
                        "format":'',
                        "bSortable":true
                        ,render: function (data, type, row)
                        {
                            return row.EndDate;
                        }
                    }
                    , {
                        "name": "Status",
                        "data": "Status",
                        "title": " 状态",
                        "sDefaultContent": "",
                        "type": 'int',
                        "format": '',
                        "bSortable": true
                        , render: function (data, type, row) {
                            switch (row.Status)
                            {
                                case 1:
                                    return "启动中";
                                    break;
                                case 2:
                                    return "办理中";
                                    break;
                                case 3:
                                    return "暂停";
                                    break;
                                case 4:
                                    return "正常结束";
                                    break;
                                case 5:
                                    return "终止";
                            }
                        }
                    }

            ,CONSTANT.DATA_TABLES.COLUMN.LASTMODIFYDATE

    , CONSTANT.DATA_TABLES.COLUMN.ACTIONBTN("ProcessId", "@Url.Action("Edit")")
    ],
        "fnServerParams": function (data) {
            data["FlowId"] = $("#FlowId").val();
            data["Status"] = $("#ProcessStatus").val();
            
    data.keyWord = $("#keyWord").val();//搜索参数
    }
    });

    });


    </script>
}
